using EstateMan.Domain;
using FizzWare.NBuilder;

namespace EstateMan.DataAccess.Migrations
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<EstateManContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;          
        }

        protected override void Seed(EstateManContext context)
        {
            var properties = Builder<Property>.CreateListOfSize(10).All()
                                             .With(x => x.PropertyType = Builder<PropertyType>.CreateNew().With(y => y.Name = "House").Build())
                                             .With(x => x.SubPropertyType = Builder<PropertyType>.CreateNew().With(y => y.Name = "Detached").Build())
                                             .With(x => x.Address = Builder<Address>.CreateNew().Build())
                                             .With(x => x.Agent = Builder<Agent>.CreateNew().Build())
                                             .Build();

            context.Set<Property>().AddOrUpdate(p => p.Name, properties.ToArray());

            
        }
    }
}
